<?php
namespace App\Models;

use Zizaco\Entrust\EntrustRole;

class Role extends EntrustRole
{
    protected $table='roles';
    protected $fillable=[
        'name',
        'label',
        'description',
    ];


    /**
     * update
     * @param array $PermissionsId
     */
    public function givePermissions(array $PermissionsId){
        $this->detachPermissions($this->perms);
        $this->attachPermissionId($PermissionsId);
    }

    /**
     * Attach multiple $PermissionsId to a user
     *
     *
     */
    public function attachPermissionId($PermissionsId)
    {
        foreach ($PermissionsId as $pid) {
            $this->attachPermission($pid);
        }
    }
}